package util;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtil {
	private static final SessionFactory sf=buildSessionFactory();

	private static SessionFactory buildSessionFactory() {
		Configuration cfg=new Configuration().configure();
		//StandardServiceRegistry ssr=new StandardServiceRegistryBuilder().applySettings(cfg.getProperties()).build();
		System.out.println(cfg.getProperty("hbm2ddl.auto"));
		System.out.println(cfg.getProperty("connection.password"));
		System.out.println(cfg.getProperty("connection.url"));
		//return cfg.buildSessionFactory(ssr);
		return cfg.buildSessionFactory();
		
	}
	public static SessionFactory getSessionFactory(){
		return sf;
	}
	public static Session getCrtSession(){
		Session s=HibernateUtil.getSessionFactory().getCurrentSession();
		s.beginTransaction();
		return s;
	}
}
